package com.design.singleton.lazy.test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class LazySingleton {
    private static LazySingleton instance;

    private LazySingleton() {
        // 私有构造方法
    }

    public static LazySingleton getInstance() {
        if (instance == null) {
            instance = new LazySingleton();
        }
        return instance;
    }

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                LazySingleton singleton = LazySingleton.getInstance();
                System.out.println(Thread.currentThread().getName() + ": " + singleton);
            });
        }

        executorService.shutdown();
    }
}
